<?php

namespace App\Models;

use Illuminate\Database\Eloquent\Model;

class Category extends Model {

	protected $guarded = array('id');
	
	public function books() {
		return $this->hasMany('App\Models\Book');
	}
	
	public function depth($depth = 0) {
		if(!is_null($this->superCategory)) {
			$depth ++;
			$depth = $this->superCategory->depth($depth);
		}
		return $depth;
	}
	
}
